<!DOCTYPE html><html><head><meta charset=utf-8><title>H3DU.SurfaceBuilder</title></head><body><h1> H3DU.SurfaceBuilder</h1><p><a href='index.html'>Back to documentation index.</a></p><a name='H3DU.SurfaceBuilder'></a>
<h3> H3DU.SurfaceBuilder()</h3>An evaluator of surface evaluator objects for generating
vertex attributes for a surface.<p>
For more information, see the <a href="tutorial-surfaces.html">Parametric Curves and Parametric Surfaces</a> tutorial.<h3> Methods</h3><ul><li><a href='#H3DU.SurfaceBuilder_attribute'>attribute</a><br>Sets the parametric surface used to generate vertex attribute values.<li><a href='#H3DU.SurfaceBuilder_clearVertices'>clearVertices</a><br>Clears the arrays of attribute values (such as positions and normals)
and vertex indices generated so far.<li><a href='#H3DU.SurfaceBuilder_evalSurface'>evalSurface</a><br>Generates the vertex attributes of the parametric surfaces.<li><a href='#H3DU.SurfaceBuilder_position'>position</a><br>Sets the parametric surface used to generate vertex positions.<li><a href='#H3DU.SurfaceBuilder_positionNormal'>positionNormal</a><br>Sets the parametric surface used to generate vertex positions and normals.<li><a href='#H3DU.SurfaceBuilder_positionNormalTexCoord'>positionNormalTexCoord</a><br>Sets the parametric surface used to generate vertex positions and normals, and
sets a surface evaluator that generates texture coordinates ranging
from (0,1) along the U and V axes of the surface.<li><a href='#H3DU.SurfaceBuilder_positionTexCoord'>positionTexCoord</a><br>Sets the parametric surface used to generate vertex positions, and
sets a surface evaluator that generates texture coordinates ranging
from (0,1) along the U and V axes of the surface.<li><a href='#H3DU.SurfaceBuilder.surfaceToBuffer'>surfaceToBuffer</a><br>Convenience method for creating a mesh buffer from a parametric
surface.<li><a href='#H3DU.SurfaceBuilder_texCoord'>texCoord</a><br>Sets the parametric surface used to generate texture coordinates.<li><a href='#H3DU.SurfaceBuilder_toMeshBuffer'>toMeshBuffer</a><br>Generates a mesh buffer containing the vertex attributes
generated so far.</ul><a name='H3DU.SurfaceBuilder_attribute'></a>
<h3> H3DU.SurfaceBuilder#attribute(surface, semantic, [semanticIndex], [size])</h3>Sets the parametric surface used to generate vertex attribute values.<h4> Parameters</h4><ul><li><code>surface</code> (Type: Object)<br>A <a href="H3DU.Surface.html">surface evaluator object</a> that describes the parametric surface used to generate attribute's values.<li><code>semantic</code> (Type: number | string)<br>An attribute semantic, such as <a href="H3DU.Semantic.html#H3DU.Semantic.POSITION">H3DU.Semantic.POSITION</a>, "POSITION", or "TEXCOORD_0". Throws an error if this value is a string and the string is invalid.<li><code>semanticIndex</code> (Type: number) (optional)<br>The set index of the attribute for the given semantic. 0 is the first index of the attribute, 1 is the second, and so on. This is ignored if "name" is a string. If null or undefined, this value is 0.<li><code>size</code> (Type: number) (optional)<br>The number of elements in each position and normal. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 3. Throws an error if this value is 0 or less.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<h4> Example</h4><p>The following example sets the surface
function for texture coordinates to a linear evaluator. Thus, coordinates passed to the
evalSurface method will be interpolated as direct
texture coordinates.</p><pre>
surface.attribute({"evaluate":function(u,v) {
"use strict"; return [u,v] }},H3DU.Semantic.TEXCOORD);</pre><a name='H3DU.SurfaceBuilder_clearVertices'></a>
<h3> H3DU.SurfaceBuilder#clearVertices()</h3>Clears the arrays of attribute values (such as positions and normals)
and vertex indices generated so far. The attributes themselves will remain.<h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<a name='H3DU.SurfaceBuilder_evalSurface'></a>
<h3> H3DU.SurfaceBuilder#evalSurface([mode], [un], [vn], [u1], [u2], [v1], [v2])</h3>Generates the vertex attributes of the parametric surfaces.<h4> Parameters</h4><ul><li><code>mode</code> (Type: number) (optional)<br>If this value is <a href="H3DU.Mesh.html#H3DU.Mesh.TRIANGLES">H3DU.Mesh.TRIANGLES</a>, or is null, undefined, or omitted, generates a series of triangles defining the surface. If this value is <a href="H3DU.Mesh.html#H3DU.Mesh.LINES">H3DU.Mesh.LINES</a>, generates a series of lines defining the surface. If this value is <a href="H3DU.Mesh.html#H3DU.Mesh.POINTS">H3DU.Mesh.POINTS</a>, generates a series of points along the surface. For any other value, this method has no effect.<li><code>un</code> (Type: number) (optional)<br>Number of subdivisions along the U axis. Default is 24. If 0, this method has no effect. Throws an error if this value is less than 0.<li><code>vn</code> (Type: number) (optional)<br>Number of subdivisions along the V axis. Default is 24. If 0, this method has no effect. Throws an error if this value is less than 0.<li><code>u1</code> (Type: number) (optional)<br>Starting U coordinate of the surface to evaluate. Default is the starting U coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 0 if not given.<li><code>u2</code> (Type: number) (optional)<br>Ending U coordinate of the surface to evaluate. Default is the ending U coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 1 if not given.<li><code>v1</code> (Type: number) (optional)<br>Starting V coordinate of the surface to evaluate. Default is the starting V coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 0 if not given.<li><code>v2</code> (Type: number) (optional)<br>Ending V coordinate of the surface to evaluate. Default is the ending V coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 1 if not given.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<a name='H3DU.SurfaceBuilder_position'></a>
<h3> H3DU.SurfaceBuilder#position(surface, [size])</h3>Sets the parametric surface used to generate vertex positions.<h4> Parameters</h4><ul><li><code>surface</code> (Type: Object)<br>A <a href="H3DU.Surface.html">surface evaluator object</a> that describes the parametric surface used to generate position values.<li><code>size</code> (Type: number) (optional)<br>The number of elements in each position value. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 3. Throws an error if this value is 0 or less.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<a name='H3DU.SurfaceBuilder_positionNormal'></a>
<h3> H3DU.SurfaceBuilder#positionNormal(surface, [size])</h3>Sets the parametric surface used to generate vertex positions and normals.<h4> Parameters</h4><ul><li><code>surface</code> (Type: Object)<br>A <a href="H3DU.Surface.html">surface evaluator object</a> that describes the parametric surface used to generate positions.<li><code>size</code> (Type: number) (optional)<br>The number of elements in each position and normal. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 3. Throws an error if this value is 0 or less.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<a name='H3DU.SurfaceBuilder_positionNormalTexCoord'></a>
<h3> H3DU.SurfaceBuilder#positionNormalTexCoord(surface, [size])</h3>Sets the parametric surface used to generate vertex positions and normals, and
sets a surface evaluator that generates texture coordinates ranging
from (0,1) along the U and V axes of the surface.<h4> Parameters</h4><ul><li><code>surface</code> (Type: Object)<br>A <a href="H3DU.Surface.html">surface evaluator object</a> that describes the parametric surface used to generate positions.<li><code>size</code> (Type: number) (optional)<br>The number of elements in each position and normal. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 3. The texture coordinates will be 2-dimensional.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<a name='H3DU.SurfaceBuilder_positionTexCoord'></a>
<h3> H3DU.SurfaceBuilder#positionTexCoord(surface, [size])</h3>Sets the parametric surface used to generate vertex positions, and
sets a surface evaluator that generates texture coordinates ranging
from (0,1) along the U and V axes of the surface.<h4> Parameters</h4><ul><li><code>surface</code> (Type: Object)<br>A <a href="H3DU.Surface.html">surface evaluator object</a> that describes the parametric surface used to generate positions.<li><code>size</code> (Type: number) (optional)<br>The number of elements in each position. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 3. The texture coordinates will be 2-dimensional. Throws an error if this value is 0 or less.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<a name='H3DU.SurfaceBuilder.surfaceToBuffer'></a>
<h3> (static) H3DU.SurfaceBuilder.surfaceToBuffer(surface, [mode], [un], [vn], [u1], [u2], [v1], [v2])</h3>Convenience method for creating a mesh buffer from a parametric
surface. The mesh buffer will contain positions, vertex normals, and
texture coordinates that cover the given surface.<h4> Parameters</h4><ul><li><code>surface</code> (Type: Object)<br>A <a href="H3DU.Surface.html">surface evaluator object</a> that describes the parametric surface used to generate positions.<li><code>mode</code> (Type: number) (optional)<br>If this value is <a href="H3DU.Mesh.html#H3DU.Mesh.TRIANGLES">H3DU.Mesh.TRIANGLES</a>, or is null, undefined, or omitted, generates a series of triangles defining the surface. If this value is <a href="H3DU.Mesh.html#H3DU.Mesh.LINES">H3DU.Mesh.LINES</a>, generates a series of lines defining the surface. If this value is <a href="H3DU.Mesh.html#H3DU.Mesh.POINTS">H3DU.Mesh.POINTS</a>, generates a series of points along the surface. For any other value, this method has no effect.<li><code>un</code> (Type: number) (optional)<br>Number of subdivisions along the U axis. Default is 24.<li><code>vn</code> (Type: number) (optional)<br>Number of subdivisions along the V axis. Default is 24.<li><code>u1</code> (Type: number) (optional)<br>Starting U coordinate of the surface to evaluate. Default is the starting U coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 0 if not given.<li><code>u2</code> (Type: number) (optional)<br>Ending U coordinate of the surface to evaluate. Default is the ending U coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 1 if not given.<li><code>v1</code> (Type: number) (optional)<br>Starting V coordinate of the surface to evaluate. Default is the starting V coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 0 if not given.<li><code>v2</code> (Type: number) (optional)<br>Ending V coordinate of the surface to evaluate. Default is the ending V coordinate given by the <a href="H3DU.Surface.html">surface evaluator object</a>, or 1 if not given.</ul><h4> Return Value</h4>The generated mesh buffer. (Type: <a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a>)<a name='H3DU.SurfaceBuilder_texCoord'></a>
<h3> H3DU.SurfaceBuilder#texCoord(surface, [size])</h3>Sets the parametric surface used to generate texture coordinates.<h4> Parameters</h4><ul><li><code>surface</code> (Type: Object)<br>A <a href="H3DU.Surface.html">surface evaluator object</a> that describes the parametric surface used to generate texture coordinates.<li><code>size</code> (Type: number) (optional)<br>The number of elements in each value of the attribute. For example, if the attribute is 3-dimensional, this parameter is 3. If null, undefined, or omitted, the default is 2.</ul><h4> Return Value</h4>This object. (Type: <a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a>)<a name='H3DU.SurfaceBuilder_toMeshBuffer'></a>
<h3> H3DU.SurfaceBuilder#toMeshBuffer()</h3>Generates a mesh buffer containing the vertex attributes
generated so far. The mesh buffer's primitive type will equal the
last type passed to the "mode" parameter in the H3DU.SurfaceBuilder.surfaceEval method.<h4> Return Value</h4>The generated mesh buffer. (Type: <a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a>)<p><a href='index.html'>Back to documentation index.</a></p></body></html>
